﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IHISCETeim.Library;
using System.Data;
using IHISCETeim.BLL;
using IHISCETeim.Model;
using System.Text;
namespace IHISCETeim.Web.MachineSys.FTradeModel
{
    public partial class FTradeWarehouseFeeList : EasyUIPageBase
    {

        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.查看, Permission.修改, Permission.新增, Permission.删除 };
            }
        }
        protected override string DWZRef
        {
            get
            {
                return "FTradeWarehouseFeeList";
            }
        }

        #region 属性 (查询条件)


        protected string JingXiaoShang
        {
            get
            {
                return GetRequestValue<string>("JingXiaoShang", "");

            }
        }
       
        protected string XingHao
        {
            get
            {
                return GetRequestValue<string>("XingHao", "");

            }
        }
        protected string JiHao
        {
            get
            {
                return GetRequestValue<string>("JiHao", "");

            }
        }


        #endregion
        /// <summary>
        /// 排序字段 值为 id
        /// </summary>
        protected override string orderField
        {
            get
            {
                return string.IsNullOrEmpty(base.orderField) ? "ID" : base.orderField;
            }
        }
        /// <summary>
        ///  排序方式 desc或 asc
        /// </summary>
        protected override string orderDirection
        {
            get
            {
                return string.IsNullOrEmpty(base.orderDirection) ? "desc" : base.orderDirection;
            }
        }
        protected override string SQLSort
        {
            get
            {
                if (orderField == "JiHao")
                {
                    return orderField + " " + orderDirection;
                }
                return (orderField + " " + orderDirection + "  ");
            }
        }
        protected string GetSQLWhere()
        {
            //营业经理权限 2014-02-21

            string wheresql = "";

            string sqlcommonFiled = "";
            if (!string.IsNullOrEmpty(JingXiaoShang))
            {
                sqlcommonFiled = QueryOperatorsEnumHelper.ConvertCommonOperator("JingXiaoShang", QueryOperatorsEnum.包含, JingXiaoShang);
                if (!string.IsNullOrEmpty(wheresql))
                {
                    wheresql += " and " + sqlcommonFiled;
                }
                else
                {
                    wheresql = sqlcommonFiled;
                }
            }


            string dutySQL = "";
            if (!string.IsNullOrEmpty(XingHao))
            {
                dutySQL = QueryOperatorsEnumHelper.ConvertCommonOperator("XingHao", QueryOperatorsEnum.包含, XingHao);
                if (!string.IsNullOrEmpty(wheresql))
                {
                    wheresql += " and " + dutySQL;
                }
                else
                {
                    wheresql = dutySQL;
                }
            }
            dutySQL = "";
            if (!string.IsNullOrEmpty(JiHao))
            {
                dutySQL = QueryOperatorsEnumHelper.ConvertCommonOperator("JiHao", QueryOperatorsEnum.包含, JiHao);
                if (!string.IsNullOrEmpty(wheresql))
                {
                    wheresql += " and " + dutySQL;
                }
                else
                {
                    wheresql = dutySQL;
                }
            }



            return wheresql;
        }
        protected override string query()
        {

            // return "";
            DataTable dts = FTradeWarehouseFeeController.GetPagination(GetSQLWhere(), pageNum, numPerPage, SQLSort, ref TotalCount);

            return ToDataGridJson(dts, TotalCount, null).ToString();
        }
    }
}